package apps.project.upload;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import apps.project.domain.ProjectManageBean;

import core.tool.common.StringHelper;
import core.tool.common.SystemInfo;
import core.web.spring.SpringMVCUtils;

@Controller
@RequestMapping("/upload")
public class UploadController {
	
    @Autowired
	private UploadFileService uploadFileService;	
    
    
	@RequestMapping("/uflist")
	public @ResponseBody Object getUploadFileList(@RequestParam("appid")String appid,@RequestParam("page")int page,@RequestParam("size")int size) {
		Page<UploadFileBean> pageResult=uploadFileService.findByAppid(appid, page, size);	
        Map attributes = SpringMVCUtils.getPager(pageResult, null,false);
		return attributes;
	}    
	
	@RequestMapping("/addFile")
	public void addFileRecord(@ModelAttribute UploadFileBean uploadFileBean) {
		uploadFileService.addFile(uploadFileBean);
	} 	

	
	

}
